﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LItemList.aspx.cs" Inherits="ZX.WebApp.List" %>

<%@ Register assembly="ZX.Web.UI.Controls" namespace="ZX.Web.UI.Controls" tagprefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//Dth XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/Dth/xhtml1-transitional.dth">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="/Scripts/JavaScript/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="/Scripts/JavaScript/themes/icon.css" />
	<script type="text/javascript" src="/Scripts/JavaScript/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="/Scripts/JavaScript/jquery.easyui.min.js"></script>
    <script src="/Scripts/JavaScript/jquery.json-2.2.min.js" type="text/javascript"></script>
    <script src="/Scripts/JavaScript/Jquery.form.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $('#tt').datagrid({
            url: 'AjaxData/JSONList.aspx',
            queryParams: { n: Math.random(), entity: 'DataListTemplate' },
            pagination: false,
            method: 'get',
            frozenColumns: [[
	                { field: 'ck', checkbox: true }
				]],
            toolbar: [{
                text: '新增',
                iconCls: 'icon-add',
                handler: open1
            }, '-', {
                text: '修改',
                iconCls: 'icon-edit',
                handler: getSelected
            }, '-', {
                text: '刪除',
                iconCls: 'icon-remove',
                handler: getSelections
            }]
        });

        $('#test').combobox({
            url: '../AjaxData/DicJson.aspx?class=1',
            valueField: 'Value',
            textField: 'Text'
        });

    });

    var entity = "E_Department";
    var url = "/AjaxData/SaveData.aspx";


    function getSelected() {
        open1();
        var selected = $('#tt').datagrid('getSelected');
        if (selected != null) {
            $.JSONToForm($.toJSON(selected));
        }
        //alert(selected.MenuID + ":" + selected.ParentID);
    }
    function getSelections() {
        var ids = [];
        var rows = $('#tt').datagrid('getSelections');
        for (var i = 0; i < rows.length; i++) {
            ids.push(eval('rows[i].MenuID'));
        }
        var s = ids.join(',');

        $('#w').DeleteData(url, entity, s);
        $('#tt').datagrid({
            url: '/AjaxData/JSONList.aspx?entity=' + entity + '&n=' + Math.random()
        });
    }

    function save() {
        var object = $('#w').extractObject();
        var s = $.toJSON(object);
        $('#w').SaveData(url, entity, s);
        $('#w').window('hide');
        $('#tt').datagrid({
            url: '/AjaxData/JSONList.aspx?entity=' + entity + '&n=' + Math.random()
        });
    }
	</script>
</head>
<body class="easyui-layout">
<div region="west" style="padding:5px;width:300px;" border="false">
</div>
<div region="center" style="padding:5px;" border="false">
	<table id="tt" fit="true">
		<thead>
            <tr>
        <cc1:DataList ID="DataList1" runat="server" >
        </cc1:DataList>
            
            </tr>
		</thead>
	</table>
</div>
<div id="w" class="easyui-window" title="部門管理" icon="icon-save" style="width:500px;height:200px;padding:5px;background: #fafafa;" closed="true">
		<div class="easyui-layout" fit="true">
			<div region="center" border="false" style="padding:10px;background:#fff;border:1px solid #ccc;">
	<form id="ff">
	<table class="style1">
        <tr>
            <td class="style3">
                部門代碼：</td>
            <td>
                <input id="DepartmentCode" type="text" name="DepartmentCode"/></td>
            <td class="style2">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style3">
                部門名稱：</td>
            <td colspan="3">
                <input id="Department" type="text" name="Department"/></td>
        </tr>

        </table>
        </form>
			</div>
			<div region="south" border="false" style="text-align:right;height:30px;line-height:30px;">
				<a class="easyui-linkbutton" icon="icon-ok" href="javascript:void(0)" onclick="save()">保存</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</div>
		</div>
	</div>
<%--    <title></title>
    <link rel="stylesheet" type="text/css" href="/Scripts/JavaScript/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="/Scripts/JavaScript/themes/icon.css" />
	<script type="text/javascript" src="/Scripts/JavaScript/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="/Scripts/JavaScript/jquery.easyui.min.js"></script>
    <script src="/Scripts/JavaScript/jquery.json-2.2.min.js" type="text/javascript"></script>
    <script src="/Scripts/JavaScript/Jquery.form.js" type="text/javascript"></script>

<script language="javascript" type="text/javascript">
    $(function () {
        LoadData();
    });
    function LoadData() {
        $('#tt').datagrid({
            url: '../AjaxData/JSONList.aspx',
            queryParams: { n: Math.random(), entity: 'E_Department' },
            pagination: true,
            method: 'get',
            frozenColumns: [[
	                { field: 'ck', checkbox: true },
	                { title: '部門代碼', field: 'DepartmentCode', width: 80, sortable: true }
				]],
            toolbar: [{
                text: '新增',
                iconCls: 'icon-add',
                handler: open1
            }, '-', {
                text: '修改',
                iconCls: 'icon-edit',
                handler: getSelected
            }, '-', {
                text: '刪除',
                iconCls: 'icon-remove',
                handler: getSelections
}]
            });
}

        var entity = "E_Department";
        var url = "../AjaxData/SaveData.aspx";
        

        function getSelected() {
            open1();
            var selected = $('#tt').datagrid('getSelected');
            if (selected != null) {
                $.JSONToForm($.toJSON(selected));
            }
            //alert(selected.MenuID + ":" + selected.ParentID);
        }
        function getSelections() {
            var ids = [];
            var rows = $('#tt').datagrid('getSelections');
            for (var i = 0; i < rows.length; i++) {
                ids.push(eval('rows[i].MenuID'));
            }
            var s = ids.join(',');
            
            $('#w').DeleteData(url, entity, s);
            $('#tt').datagrid({
            url: '../AjaxData/JSONList.aspx?entity=' + entity + '&n=' + Math.random()
            });
        }
        
        function save() {
            var object = $('#w').extractObject();
            var s = $.toJSON(object);      
            $('#w').SaveData(url, entity, s);
            $('#w').window('hide');
            $('#tt').datagrid({
                url: '../AjaxData/JSONList.aspx?entity='+entity+'&n=' + Math.random()
            });
        }
	</script>
</head>
<body class="easyui-layout">
    <form id="form1" runat="server">
<div region="center" style="padding:5px;" border="false">
	<table id="tt" fit="true">
		<thead>
	    <cc1:DataList ID="DataList1" runat="server" >
        </cc1:DataList>
		</thead>
	</table>
</div>
 <%--   <div id="w" class="easyui-window" title="數據查詢" icon="icon-save" style="width: 600px;
        height: 300px; padding: 5px; background: #fafafa;" closed="true">
        <div class="easyui-layout" fit="true">
            <div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
                <iframe id="dataQuery" frameborder='0' src="QueryForm.html" width="100%" height="100%">
                </iframe>
            </div>
        </div>
    </div>

        <div id="upload" class="easyui-window" title="数据导入" icon="icon-save" style="width: 350px;
        height: 120px; padding: 5px; background: #fafafa;" closed="true">
        <div class="easyui-layout" fit="true">
            <div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
                暂时仅支持CSV格式:<br />
                <input type="file" /><button>上传</button>
                </iframe>
            </div>
        </div>
    </div>
    </form>--%>
</body>
</html>
